package com.tensequare.search.service;

import com.tensequare.search.dao.ArticleDao;
import com.tensequare.search.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

/**
 * @Author: Feng.Wang
 * @Company: Zelin.ShenZhen
 * @Description:
 * @Date: Create in 2019/3/26 16:02
 */
@Service
public class ArticleService {
    @Autowired
    private ArticleDao articleDao;

    /**
     * 保存到索引库
     * @param article
     */
    public void save(Article article){
        articleDao.save(article);
    }

    public Page<Article> findByTitleOrContentLike(String keywords, int page, int size) {
        return articleDao.findByTitleOrContentLike(keywords,keywords, PageRequest.of(page-1,size));
    }
}
